package stuman.activity;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

import stuman.entity.Student;
import stuman.util.Container;

import com.StuMan.R;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class Login extends Activity {
	
	 @Override
	 public void onCreate(Bundle savedInstanceState) {
		 super.onCreate(savedInstanceState);
	     setContentView(R.layout.welcome);
	 }
	 
	 public void loginClick(View view){
		 EditText name = (EditText) findViewById(R.id.txtName);
		 Student stu;
		 if (studentExist(name.toString())){
			 stu = Container.getStudent(name.toString());
		 }
		 else {
			 stu = new Student(name.getText().toString(), null);
			 Container.students.add(stu);
		 }
		 Intent intent = new Intent(Login.this, OpenPage.class);
		 //intent.putExtra("student", stu.getFirstName().toString());
		 startActivity(intent);
	 }
	 
	 public Boolean studentExist(String s){
		 if (Container.getStudent(s) != null){
			 return true;
		 }
		 else return false;
	 }
	 
	 public void viewTabs(View view){
		 Intent intent = new Intent(Login.this, TabPage.class);
		 startActivity(intent);
	 } 

}
